package dk.dashboardFP.interactionElementFramwork.smartButton {
	import dk.dashboardFP.interactionElementFramwork.buttonViews.AbstractButtonView;
	import dk.dashboardFP.interactionElementFramwork.buttons.AbstractButton;
	import dk.dashboardFP.interactionElementFramwork.buttons.ButtonEvent;

	import flash.events.Event;

	/**
	 * @author jk
	 */
	 
	public class SmartButton extends AbstractButtonView {
		private var _oController : AbstractButton;
		protected var _oRefrenceObject : Object;

		public function SmartButton(oRefrenceObject:Object=null) {
			_oRefrenceObject = oRefrenceObject;
			super();
			setupController();
		}
		
		private function setupController() : void {
			
			//::
			// controllser 
			_oController=new AbstractButton(this, _oRefrenceObject);
			_oController.addEventListener(ButtonEvent.CLICKED, onButtonClicked, false, 0, true);
		}
		
		protected function onButtonClicked(event : ButtonEvent) : void {
			
			dispatchEvent(event.clone());
			dispatchEvent(get_oClickEvent());
			
		}

		protected function get_oClickEvent() : Event {
			return new SmartButtonEvent(SmartButtonEvent.CLICKED, true, _oRefrenceObject);
		}

		public function get oController() : AbstractButton {
			return _oController;
		}
		
		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
		// link dispatcher
		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
		
		public function get oRefrenceObject() : Object {
			return _oRefrenceObject;
		}
	}
}
